package com.nov.audiodemo;

import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

public class MainActivity extends AppCompatActivity {

    StandardGSYVideoPlayer videoPlayer;
    OrientationUtils orientationUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {
        videoPlayer = (StandardGSYVideoPlayer) findViewById(R.id.video_player);

        String source1 = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";

//        String url = "http://192.168.5.165:8080/shuidi.mp3";
//        String url = "file:///android_asset/naoshi.mp3";
//        GSYVideoManager.instance().enableRawPlay(getApplicationContext());
        String url = "android.resource://" + getPackageName() + "/" + R.raw.sea;
//        String url = "file://"+ Environment.getExternalStorageDirectory().getPath() + "/leishen.mp3";
        videoPlayer.setUp(url, true, "测试视频");
        videoPlayer.setLooping(true);


        videoPlayer.getStartButton().performClick();


    }

    public void click(View v) {

//        String url = "file://"+ Environment.getExternalStorageDirectory().getPath() + "/leishen.mp3";
        String url = "android.resource://" + getPackageName() + "/" + R.raw.leishen;
        videoPlayer.setUp(url, true, "测试视频");
        videoPlayer.getStartButton().performClick();
    }

    @Override
    protected void onPause() {
        super.onPause();
//        videoPlayer.onVideoPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
//        videoPlayer.onVideoResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();

    }

    @Override
    public void onBackPressed() {
        //释放所有
        videoPlayer.setVideoAllCallBack(null);
        super.onBackPressed();
    }
}
